package com.tencent.stat;

import android.content.Context;
import com.tencent.stat.common.StatCommonHelper;
import com.tencent.stat.common.StatLogger;

final class n
  implements Runnable
{
  public final void run()
  {
    if (this.a == null)
      StatServiceImpl.f().error("The Context of StatService.onStop() can not be null!");
    do
    {
      return;
      StatServiceImpl.flushDataToDB(this.a);
    }
    while (StatServiceImpl.a());
    while (true)
      try
      {
        do
          Thread.sleep(100L);
        while (!(StatCommonHelper.isBackgroundRunning(this.a)));
        if (StatConfig.isDebugEnable())
          StatServiceImpl.f().i("onStop isBackgroundRunning flushDataToDB");
        StatServiceImpl.commitEvents(this.a, -1);
        return;
      }
      catch (InterruptedException localInterruptedException)
      {
        localInterruptedException.printStackTrace();
      }
  }
}